import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginView from '../components/LoginView.vue'
import HomePage from '../views/HomePage'
import UserView from '../components/UserView'
import OrderView from '../components/OrderView'
import BookView from '../components/BookView'
import BookImg from '../components/BookImg'
import BookClasses from '../components/BookClasses'
import ClassView from '../components/ClassView'
import PostView from '../components/PostView'
import ApplyView from '../components/ApplyView.vue'
import NoticeView from '../components/NoticeView'
import PostDetails from '../components/PostDetails.vue'
import CarouselView from '../components/CarouselView'
import DataStatistics from '../components/DataStatistics'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login' // 设置重定向  
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/details',
    name: 'details',
    component: PostDetails
  },
  {
    path: '/home',
    name: 'home',
    component: HomePage,
    children: [
      {
        path: '/user',
        name: 'user',
        component: UserView
      },
      {
        path: '/order',
        name: 'order',
        component: OrderView
      },
      {
        path: '/book',
        name: 'book',
        component: BookView
      },
      {
        path: '/bookImg',
        name: 'bookImg',
        component: BookImg
      },
      {
        path: '/bookClasses',
        name: 'bookClasses',
        component: BookClasses
      },
      {
        path: '/class',
        name: 'class',
        component: ClassView
      },
      {
        path: '/post',
        name: 'post',
        component: PostView
      },
      {
        path: '/apply',
        name: 'apply',
        component: ApplyView
      },
      {
        path: '/notice',
        name: 'notice',
        component: NoticeView
      },
      {
        path: '/statistics',
        name: 'statistics',
        component: DataStatistics
      },
      {
        path: '/carousel',
        name: 'carousel',
        component: CarouselView
      }
    ]
  },
]

const router = new VueRouter({
  // 使用 HTML5 History 模式
  mode: 'history',
  routes
})

export default router
